home *** CD-ROM | disk | FTP | other *** search
- Path: fido.asd.sgi.com!austern
- From: mkt@isun04.inf.uni-jena.de (Tilo Koerbs)
- Newsgroups: comp.std.c++
- Subject: Re: Explicit constructor call vs Temporaries
- Date: 01 Feb 1996 09:54:08 PST
- Organization: Lehrstuhl fuer Rechnerarchitektur- und kommunikation, FSU Jena
- Approved: austern@isolde.mti.sgi.com
- Message-ID: <4eq5p2$fpu@fsuj01.rz.uni-jena.de>
- References: <4e6plv$idn@eclipse.eng.sc.rolm.com>
- Reply-To: mkt@isun04.inf.uni-jena.de
- NNTP-Posting-Host: isolde.mti.sgi.com
- X-Original-Date: 1 Feb 1996 10:48:02 GMT
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBVAwUBMRD+cEy4NqrwXLNJAQESygIAo8MetEfyblp+r84Bvt1eaxl42v0Sortl
- GvcHxkF3eLnDj9aEMhjb0fQ9CYQ0BEaRqG6iiWy4ZiIntGrvtmohFA==
- =7Qw+
- Originator: austern@isolde.mti.sgi.com
-
- About the error message in this posted code:
-
- > class T {
- > T();
- > ~T();
- > }
- >
- > class X {
- > X();
- > ~X();
- > f(T& t);
- > }
- >
- > int main() {
- > X x;
- > x.f(T()); // Compiler complained on this line
- > }
-
- The 'temporary' (it is an UNNAMED) T()-object is NOT const!
- Consider:
- class T {
- public:
- T();
- ~T();
- void nonConstFct() {}
- };
-
- int main() {
- T().nonConstFct(); // Allowed!!!
- }
-
- And so the compiler should have no problem with this code!
- I compiled it without any problem!
-
- Bye.
- ---
- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
- Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
- is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
-